#include<stdio.h>
#include<stdlib.h>
int x, y;
int height, width;
int enemy_x, enemy_y;
int bullet_x, bullet_y;
int input;

void startup()
{
	height = 18, width = 30;
	x = height / 2, y = width / 2;
	bullet_x = -1;
	bullet_y = y;
	enemy_x = x;
	enemy_y = y;
}
void show()
{
	system("cls");
	int i, j;
	for (i = 0; i < height; i++)
	{
		for (j = 0; j < width; j++)
		{
			if (i == x && j == y)
				printf("o");
			else if (i == bullet_x && j == bullet_y)
				printf("|");
			else
				printf(" ");

		}
		printf("\n");
	}
}
void updateWithoutInput()
{
	bullet_x--;
	enemy_x++;
}
void updateWithInput()
{
	char input;
	if (kbhit())
	{
		input = _getch();
		if (input == 'a')
			y--;
		if (input == 'w')
			x--;
		if (input == 's')
			x++;
		if (input == 'd')
			y++;
		if (input == ' ')
		{
			bullet_x = x - 1;
			bullet_y = y;
		}
	}
}
int main()
{
	startup();
	while (1)
	{
		show();
		updateWithoutInput();
		updateWithInput();
	}
	system("pause");
	return 0;
}